fix: write .claude.json to ~/.claude/ instead of homedir root - #1335
fix: write .claude.json to ~/.claude/ instead of homedir root#1335p2p3p wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthrough
ChangesConfiguration path resolution
Estimated code review effort: 1 (Trivial) | ~3 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/utils/env.ts`:
- Around line 25-28: Update the directory argument in the configuration path
construction to use getClaudeConfigHomeDir() directly, removing the
process.env.CLAUDE_CONFIG_DIR || fallback expression. Preserve joining the
resolved directory with filename so empty environment values follow the helper’s
home-directory behavior.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
| return join( | ||
| process.env.CLAUDE_CONFIG_DIR || getClaudeConfigHomeDir(), | ||
| filename, | ||
| ) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Use getClaudeConfigHomeDir() as the sole directory resolver.
When CLAUDE_CONFIG_DIR is set to an empty string, getClaudeConfigHomeDir() returns "" because it uses ??. The || expression therefore still yields "", and join("", filename) resolves to the current working directory instead of ~/.claude/. This can split or misplace the global configuration. Use the helper directly.
Proposed fix
return join(
- process.env.CLAUDE_CONFIG_DIR || getClaudeConfigHomeDir(),
+ getClaudeConfigHomeDir(),
filename,
)🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/utils/env.ts` around lines 25 - 28, Update the directory argument in the
configuration path construction to use getClaudeConfigHomeDir() directly,
removing the process.env.CLAUDE_CONFIG_DIR || fallback expression. Preserve
joining the resolved directory with filename so empty environment values follow
the helper’s home-directory behavior.
将 .claude.json 写入路径从 homedir() 根目录改为 getClaudeConfigHomeDir() 对应的 ~/.claude/ 目录。
Summary by CodeRabbit